CONFESSIONS OF A NOVICE PROGRAMMER

by

Norman

copyright 2005

Home

SpriteByte

Handling Data

Data Six Pak

Kaliedoscope

Drag and Drop

Simulations w/LB

Design Template

Demos:

Simulated Hyperlink

Slideshow

Space Travel

Corrections:

TransparentBlt Fix

Video Capture Fix


Newsletter help

Index

I have been checking back to when I first became interested in computers. I had thought that it was in the 1960s. However, I now realize that it was later than that. My first computer was a Tandy TRS80 with 16K RAM. I bought it in 1977 or 1978. I knew absolutely nothing about programming so I bought computer magazines which, in those days, carried lots of program listings for you to type into your computer. It was by typing in hundreds of programs that I began to understand the BASIC language. Today, of course, I copy/paste programs and learn nothing.

In 1982, I bought a Lynx 48K computer. Unfortunately, this computer never made any real progress and went out of production.

In 1984, I bought the Sinclair QL 128k computer. This is when I really started to expand my knowledge of BASIC programming. Over the next few years, I learned how to use the QLs Procedures and Functions, and I became quite good at all forms of string manipulation.

Next, about 1997, I bought a Packard Bell and had my first introduction to Windows. I soon became quite disillusioned with QBasic, as I could not seem to understand how to do many of the things that I had become used to doing with QL SuperBasic. I simply gave up programming.

A couple of years ago, I discovered Liberty Basic, and my programming instincts began to come into play once again. I could see that Liberty Basic would allow me to program in a way very similar to the way that I had taught myself all those years ago.

Now, I am using Liberty Basic to create lots of programs just using the techniques from my Sinclair QL days. However, I realize that Liberty Basic has many more commands and functions that I have not used at all (mainly because I don't understand them and have not bothered to try to learn about them).

Well, in the last few days, I decided to take some time out from writing programs that read files or downloaded web pages and manipulate text, etc., and thought that I would try to write a very simple program using graphics (something that I have steered clear of until now).

What would I like my program to do?

While pondering this, my mind was taken back about 55 years to when I was a young lad. I remember that I had a kaleidoscope which I would play with for hours. Just tapping the side to create those wonderful, infinite, patterns.

I wondered.... could I write a program that would create similar patterns. Well, there was only one way to find out. First, I needed to remind myself how the kaleidoscope worked. I remember that it had some triangular mirrors which reflected a pattern several times to create a symmetrical delight.

How many copies of the original pattern were there? I guessed that the original random pattern was reflected five times to create a symmetrical six sided pattern.

OK, so I started my program by learning some new commands. These were not so difficult after all. PenUp, PenDown, Go, etc. seemed to be the basis of what I would need to use. I began by working out how to draw six triangles all radiating from the same point to create a regular hexagon.. This took quite a while for me to get right, but it was worth it. I now had started to get some ideas about how I could create my kaleidoscope. I deleted the hexagon but retained some of the coding for equally spacing any given point six times around a central point.

I decide to keep it simple and started by drawing six small circles equally spaced about a central point. I next spent a bit of time learning how to fill these circles with a solid colour.

Now I started to use random distances from the central point starting at a random angle then drawing a circle of random size filled with a random colour, (repeating this in each of the six segments) to start to create my patterns.

To give more impact, I decided to start by creating a black background, on which I created a large white filled circle which would be the base for my multicoloured patterns. It began to look quite good but something was not quite right.

Ah! Suddenly I realized what was niggling at my mind. I was repeating the same pattern six times, instead of reflecting it. As soon as I realized this, it just required me to add another line of code and it was done!

I must confess that, as usual, I did pinch an occasional line of code from some example programs, rather than trying to work out my own coding. But that is something that I always do these days. I just don't seem to have the learning capacity that I had some years ago.

I will just end by saying that when I complete a program to my satisfaction, I am really pleased and quite proud of my achievement, regardless of whether it is good programming or not. In this case, I don't really care if it is viewed as a kaleidoscope pattern, or as a decorative paperweight. The result is pleasing to me and that is what matters.

I am including my Kaleidoscope program so that if anyone is interested they can have a look at it.

Norman

    NOMAINWIN
    message$="Kaleidoscope"+chr$(13)
    message$=message$+"After viewing a pattern, "
    message$=message$+"press [Esc] to quit, or any other "
    message$=message$+"key to generate a new pattern."
    notice message$

    global clr$,radius

    dim clr$(14)
    for clr=1 to 14
        read clr$
        clr$(clr)=clr$
    next clr

    WindowWidth = 500
    WindowHeight = 500
    UpperLeftX=(DisplayWidth-WindowWidth)/2
    UpperLeftY=(DisplayHeight-WindowHeight)/2

    open "Kaleidoscope" for graphics_nsb as #draw
    print #draw, "when characterInput [keyPressed]"
    print #draw, "trapclose [quit]"

[start]
    print #draw, "fill black"
    print #draw, "home"
    print #draw,"backcolor  white"
    print #draw, "down"
    print #draw,"circlefilled 200"

    loops=int(rnd(1)*75)+75
    for k=1 to loops
        distance=int(rnd(1)*183)+10
        if distance<100 then distance=int(rnd(1)*183)+10
        clr=int(rnd(1)*14)+1
        clr$=clr$(clr)
        radius=int(rnd(1)*8)+1
        angle=int(j+int(rnd(1)*28)+1)

        For j= -30 to 270 step 60
            Call Circle j+angle, distance
            Call Circle j-angle, distance
        next j
    next k

[loopHere]
    print #draw, "setfocus"
    scan
    goto [loopHere]

[keyPressed]
    key$ = Inkey$
    if right$(key$,1)=chr$(27) then [quit] else [start]
    goto [loopHere]

[quit]
    close #draw

END

Sub Circle angle,distance
  print #draw, "up"
  print #draw, "home"
  print #draw, "north"
  print #draw, "turn ";angle
  print #draw, "go "; distance
  print #draw, "down"
  print #draw, "color ";clr$
  print #draw, "backcolor ";clr$
  print #draw, "circlefilled ";radius
End Sub

DATA "blue","brown","cyan","darkblue","darkcyan"
DATA "darkgreen","darkpink","darkred","green"
DATA "lightgray","pink","red","white","yellow"


Home

SpriteByte

Handling Data

Data Six Pak

Kaliedoscope

Drag and Drop

Simulations w/LB

Design Template

Demos:

Simulated Hyperlink

Slideshow

Space Travel

Corrections:

TransparentBlt Fix

Video Capture Fix


Newsletter help

Index